// Copyright (c) 2020 Wang Zemin Personal. All Right Reserved

import React from "react";
import {NavLink, withRouter} from 'react-router-dom'
import {Menu} from 'antd';
import {
    AccountBookOutlined,
    CrownOutlined,
    KeyOutlined,
    ReadOutlined,
    SettingOutlined,
    TeamOutlined,
    UserOutlined,
    VerifiedOutlined,
} from '@ant-design/icons';
import "./sider-nav.css"
import {hasPermission} from "../requests/BaseRequest";

const {SubMenu} = Menu;

class SiderNav extends React.Component {
    render() {
        return (
            <div className="sider-nav" id="sider-nav">
                <div className="logo">
                    <div className="logo-text"/>
                </div>
                <Menu theme="light" defaultSelectedKeys={['1']} mode="inline">
                    <SubMenu key="system-manage" icon={<SettingOutlined/>} title="系统管理"
                             style={{display: hasPermission("user-manager:list") ? 'inline' : 'none'}}>
                        <Menu.Item key="user-manage" icon={<UserOutlined/>}
                                   style={{display: hasPermission("user-manager:list") ? 'inline' : 'none'}}>
                            <NavLink to="/index/system/user"><span>用户管理</span></NavLink>
                        </Menu.Item>
                        <Menu.Item key="budget-manage" icon={<AccountBookOutlined/>}
                                   style={{display: hasPermission("budget-manage:list") ? 'inline' : 'none'}}>
                            <NavLink to="/index/system/budget"><span>预算管理</span></NavLink>
                        </Menu.Item>
                        <Menu.Item key="budget-auditing-manage" icon={<ReadOutlined/>}
                                   style={{display: hasPermission("budget-auditing-manage:list") ? 'inline' : 'none'}}>
                            <NavLink to="/index/system/budget/auditing"><span>预算明细</span></NavLink>
                        </Menu.Item>
                        <Menu.Item key="role-manage" icon={<TeamOutlined/>}
                                   style={{display: hasPermission("role-manager:list") ? 'inline' : 'none'}}>
                            <NavLink to="/index/system/role"><span>角色管理</span></NavLink>
                        </Menu.Item>

                    </SubMenu>
                    <SubMenu key="own-key-manage" icon={<VerifiedOutlined/>} title="激活码"
                             style={{display: hasPermission("key-manage:list:own") ? 'inline' : 'none'}}>
                        <Menu.Item key="key-manage-own" icon={<KeyOutlined/>}
                                   style={{display: hasPermission("key-manage:list:own") ? 'inline' : 'none'}}>
                            <NavLink to="/index/key/own"><span>激活码管理</span></NavLink>
                        </Menu.Item>
                        <Menu.Item key="key-auditing-own" icon={<ReadOutlined/>}
                                   style={{display: hasPermission("key-manage:list:auditing-log:own") ? 'inline' : 'none'}}>
                            <NavLink to="/index/key/auditing/own"><span>激活码明细</span></NavLink>
                        </Menu.Item>
                    </SubMenu>

                    <SubMenu key="key-manage" icon={<CrownOutlined/>} title="激活码超管"
                             style={{display:hasPermission("key-manage:list:all") ? 'inline' : 'none'}}>
                        <Menu.Item key="key-manage-all" icon={<KeyOutlined/>}
                                   style={{display: hasPermission("key-manage:list:all") ? 'inline' : 'none'}}>
                            <NavLink to="/index/key/all"><span>激活码管理</span></NavLink>
                        </Menu.Item>
                        <Menu.Item key="key-auditing-all" icon={<ReadOutlined/>}
                                   style={{display: hasPermission("key-manage:list:auditing-log:all") ? 'inline' : 'none'}}>
                            <NavLink to="/index/key/auditing/all"><span>激活码明细</span></NavLink>
                        </Menu.Item>
                    </SubMenu>

                    {/*<SubMenu key="dashboard-manage" icon={<FundOutlined/>} title="报表管理">*/}
                    {/*    <Menu.Item key="weekly-dashboard" icon={<PieChartOutlined />}>*/}
                    {/*        <NavLink to="/index/weekly/dashboard"><span>每周图表</span></NavLink>*/}
                    {/*    </Menu.Item>*/}
                    {/*    <Menu.Item key="weekly-report" icon={<BarChartOutlined />}>*/}
                    {/*        <NavLink to="/index/key/auditing/all"><span>每周报表</span></NavLink>*/}
                    {/*    </Menu.Item>*/}
                    {/*</SubMenu>*/}
                </Menu>
            </div>
        );
    }
}

export default withRouter(SiderNav);